package cn.cloudtogo.common.atomapi.token;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @author yaolianhua789@gmail.com
 **/
@Configuration(proxyBeanMethods = false)
@ConfigurationProperties("gendb.apitoken")
@Slf4j
@Data
public class ApiTokenProperties {

    private boolean enabled = true;

    private Long appId;
    private Long groupId;

    @PostConstruct
    public void print() {
        if (enabled) {
            log.info("[Enabled api token validation]");
        }
        if (appId == null || groupId == null) {
            throw new IllegalArgumentException("Application start param is required [appId, groupId]");
        }
        log.info("[Load api token config. appId = {}, groupId = {}]", appId, groupId);
    }
}
